package log;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;

import aries.Aries;

public class Log {
	public LinkedList<LogItem> itens =new LinkedList<LogItem>();
	public HashSet<Integer> transacoes = new HashSet<Integer>();
	public Log(String caminho){
		FileInputStream stream = null;
		try {
			stream = new FileInputStream(caminho);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}  
		InputStreamReader streamReader = new InputStreamReader(stream);  
		BufferedReader reader = new BufferedReader(streamReader);
		String line = null;  
		try {
			line=reader.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		StringTokenizer st = new StringTokenizer(line,"][");
		StringTokenizer st1;
		String[] aux;
		aux = new String[6];
		int i;
	    while (st.hasMoreTokens()) {
	    	i=0;
	         st1 = new StringTokenizer(st.nextToken(),"|");
		     while (st1.hasMoreTokens()) {
		    	 aux[i]=st1.nextToken();
		    	 i++;
		     }
		     if(i==6){
		    	 LogItem item=new LogItem(Integer.parseInt(aux[0]),
		    			 Integer.parseInt(aux[1].substring(1)),
		    			 aux[2].charAt(0),
		    			 aux[3].charAt(0),
		    			 Integer.parseInt(aux[4]),
		    			 Integer.parseInt(aux[5]));
		    	 itens.add(item);		    	 
		     }
		     if(i==3){
		    	 LogItem item=new LogItem(Integer.parseInt(aux[0]),
		    			 Integer.parseInt(aux[1].substring(1)),
		    			 aux[2].charAt(0));
		    	 itens.add(item);
		     }
		     transacoes.add(itens.get(itens.size()-1).t);
	     }
	}
	public static void main(String[] args) {
		String Arquivo;
		System.out.println("Digite o nome do arquivo a ser lido:");
		Scanner scanner = new Scanner(System.in);
		//Arquivo = scanner.nextLine();
//		new Aries(new Log(Arquivo));
		new Aries(new Log("arquivo.txt"));

	}
}